{include file="header"}
<div class="x-body">
	<xblock>
		<a href="javascript:location.reload();" class="layui-btn layui-btn-warm">
			<i class="icon iconfont"></i> 广告
		</a>
		<a class="layui-btn layui-btn-danger del_t" name="确定要添加一条记录吗？" url="{:url('admin/api/add_ad',array('id'=>input('id')))}">添加</a>
		<span class="x-right" style="line-height:40px">共有数据：{:fun_st('ad',array('alias'=>input('id')))} 条</span>
	</xblock>
	<div class="layui-form-item">
	    <div class="layui-col-md6">
            <label class="layui-form-label"><button type="button" class="layui-btn layui-btn-sm up upfujian" up="fujian">上传图片</button></label>
            <div class="layui-input-block">
                <input type="text" name="pic" id="fujian" value="{$c.pic}" placeholder="上传图片自行配置到下方" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
	
	<div style="overflow: auto;">
        {volist name=":fun_s('ad',array('alias'=>input('id')),'tid asc px desc',100)" id="vo"}
        <form class="layui-form" action="">
        <input type="hidden" name="id" value="{$vo.id}">
            <table class="layui-table" style="min-width: 1000px;">
                <colgroup>
                    <col width="50">
                    <col width="100">
                    <col width="200">
                    <col width="80">
                    <col width="50">
                    <col width="100">
                    <col>
                </colgroup>
        		<thead>
        			<tr>
        			    <th>广告ID</th>
        				<th>备注</th>
        				<th>广告代码</th>
        				<th>到期时间</th>
        				<th>排序</th>
        				<th>操作</th>
        			</tr>
        		</thead>
        		<tbody>
        			<tr>
        			    <td><input type="number" name="tid" value="{$vo.tid}"  placeholder="数字" autocomplete="off"  lay-verify="required" class="layui-input"><br>调用代码<br>&#123;:ad({$vo.tid})&#125;</td>
        				<td><input type="text" name="name" value="{$vo.name}"  placeholder="备注" autocomplete="off" class="layui-input"></td>
        				<td><textarea name="config" placeholder="请输入内容" class="layui-textarea">{$vo.config}</textarea></td>
        				<td><input type="text" id="times{$vo.id}" name="times" value="{$vo.times||date='Y-m-d',###}"  placeholder="结束时间" autocomplete="off"  lay-verify="required" class="layui-input"></td>
        				<script>
                        layui.use('laydate', function(){
                          var laydate = layui.laydate;
                          laydate.render({
                            elem: '#times{$vo.id}'
                          });
                        });
                        </script>
                        <td><input type="number" name="px" value="{$vo.px}"  placeholder="数字" autocomplete="off"  lay-verify="required" class="layui-input"></td>
        				<td id="admin_set">
        				    <a class="layui-btn layui-btn-sm" lay-submit lay-filter="set_ad"><i class="layui-icon">&#xe679;</i>更新</a>
        					<a class="layui-btn layui-btn-sm layui-btn-danger del_t" url="{:url('admin/api/catedelete')}?model=ad&id={$vo.id}" name="确定要删除这条记录吗？">
        						<i class="layui-icon"></i>删除
        					</a>
        				</td>
        			</tr>
        		</tbody>
        	</table>
        </form>
        {/volist}
	</div>
</div>
<script>
layui.use('form',function(){
  var form = layui.form
  ,jq = layui.jquery;
  //更新
  form.on('submit(set_ad)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
    var param = data.field;
    jq.post('{:url("admin/api/upad")}',param,function(data){
      if(data.code == 1){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });
})
</script>
{include file="footer"}